<?php
class Pageley_Log_LoggerTests extends Pageley_Test_Case {
	
	public function testIsLevelEnabled() {
		$appender = new Pageley_Log_MockAppender();
		$logger = new Pageley_Log_Logger("Pageley_Log_LoggerTests", Pageley_Log_Level::$DEBUG, new Pageley_Util_ArrayMap($appender));
		$this->assertTrue($logger->isInfoEnabled());
		$this->assertTrue($logger->isDebugEnabled());
		$this->assertFalse($logger->isTraceEnabled());
	}
    
	public function testLog() {
		$appender = new Pageley_Log_MockAppender();
		$logger = new Pageley_Log_Logger("Pageley_Log_LoggerTests", Pageley_Log_Level::$INFO, new Pageley_Util_ArrayMap($appender));
		$logger->info("foobar");
		$timestamp = new Pageley_Util_Timestamp();
		$date = $timestamp->format("d-m-Y H:i:s");
		$this->assertEquals("[" . $date . "] [INFO] [Pageley_Log_LoggerTests] foobar\n", $appender->getLastMessage());
	}
	
	public function testLevels() {
		$appender = new Pageley_Log_MockAppender();
		$logger = new Pageley_Log_Logger("Pageley_Log_LoggerTests", Pageley_Log_Level::$INFO, new Pageley_Util_ArrayMap($appender));
		$logger->warn("foobar");
		$logger->debug("barfoo");
		$timestamp = new Pageley_Util_Timestamp();
		$date = $timestamp->format("d-m-Y H:i:s");
		$this->assertEquals("[" . $date . "] [WARN] [Pageley_Log_LoggerTests] foobar\n", $appender->getLastMessage());
	}
}